local serviceid
function on_init(id)
    print("[lua] ping oninit id : " .. id)
    serviceid = id

    -- sunnet.listen(8000, serviceid)
end

function on_exit()
    print("[lua] ping onexit")
end

function onservicemsg(source, msg)
    print('[lua] ping onservicemsg id: ' .. source)

    if string.len(msg) > 10 then
        sunnet.exit(serviceid)
    end

    sunnet.send(serviceid, source, "pong")
end

function on_socket_date(fd, msg)
    print('[lua]' .. msg)
    -- sunnet.close(fd)
end

function on_socket_close(fd)
    print('[lua] on socket close' .. fd)
end
